//
//  NetWork.h
//  TenThousand
//
//  Created by baixue on 16/6/26.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import <AFNetworking/AFNetworking.h>

#define BaseURL @"http://114.215.198.5:22853/User/GetUsers"
/**定义请求类型的枚举*/

typedef NS_ENUM(NSUInteger,HttpRequestType)
{
    
    HttpRequestTypeGet = 0,
    HttpRequestTypePost
    
};


/**定义请求成功的block*/
typedef void(^requestSuccess)( NSDictionary * object);

/**定义请求失败的block*/
typedef void(^requestFailure)( NSError *error);

/**定义上传进度block*/
typedef void(^uploadProgress)(float progress);

/**定义下载进度block*/
typedef void(^downloadProgress)(float progress);



@interface NetWork : AFHTTPSessionManager

/**
 *  单利方法
 *
 *  @return 实例对象
 */
+(instancetype)shareManager;

/**
 *  网络请求的实例方法
 *
 *  @param type         get / post
 *  @param urlString    请求的地址
 *  @param paraments    请求的参数
 *  @param successBlock 请求成功的回调
 *  @param failureBlock 请求失败的回调
 */
+(void)requestWithType:(HttpRequestType)type withUrlString:(NSString *)urlString withParaments:(id)paraments withSuccessBlock:( requestSuccess)successBlock withFailureBlock:( requestFailure)failureBlock progress:(downloadProgress)progress;



// 字符串转数组
+ (NSArray *)arrayWithJsonString:(NSString *)jsonString;


//字符串转字典
+ (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;


//反序列化
- (id)toArrayOrNSDictionary:(NSData *)jsonData;

@end
